{% load i18n %}
{% load staticfiles %}

<!DOCTYPE html>
<html lang="en">
	<head>
	{% include 'main/top.html' %}
	<title>新闻管理页面</title>
	</head>
<body>
		
<div class="container-fluid" id="main-container">


<div id="page-content" class="clearfix">
						
  <div class="row-fluid">

	<div class="row-fluid">
	
			<!-- 检索  -->
			<form action="/main/news_list" method="get" name="Form" id="Form">
			{% csrf_token %}
			<!-- 当前页 -->
			<input id="pagenum" name="pagenum" type="hidden" value='{{page.pagenum}}'>
			<input id="pagecount" name="pagecount" type="hidden" value='{{page.pagecount}}'>
			<input id="numpage" name="numpage" type="hidden" value='{{page.numpage}}'>
			
			<input id="statusold" name="statusold" type="hidden" value='{{status}}'>
			
			<table>
				<tr>
					<td>
						<span class="input-icon">
							<input autocomplete="off" id="nav-search-input" type="text" name="name" id="name" placeholder="这里标题名称" value="{{name|default_if_none:''}}" />
							<i id="nav-search-icon" class="icon-search"></i>
						</span>
					</td>
					
					<td style="vertical-align:top;"><button class="btn btn-mini btn-light" onclick="search();"  title="检索"><i id="nav-search-icon" class="icon-search"></i></button></td>
				</tr>
			</table>
			<!-- 检索  -->
		<div class="page-header position-relative">
		<table style="width:100%;">
			
			<tr>
				<td style="vertical-align:top;">
					<a class="btn btn-small btn-success" onclick="changestatu(0);">删除</a>
					<a class="btn btn-small btn-success" onclick="changestatu(1);">重新发布</a>
					<a class="btn btn-small btn-warning" onclick="addnews();">添加</a>
					<a class="btn btn-small btn-warning" onclick="editnews();">编辑</a>
					<a class="btn btn-small btn-info" onclick="view_news();">查看详情</a>
				
				</td>
			</tr>	
			</table>
			</div>
		
			<table id="table_report" class="table table-striped table-bordered table-hover">
				
				<thead>
					<tr>
						<th class="center">
						<label><input type="checkbox" id="zcheckbox" /><span class="lbl"></span></label>
						</th>		
						<th class="center">标题</th>
						<th class="center">时间</th>
						<th class="center">状态</th>
						<th class="center">简介</th>
					</tr>
				</thead>
										
				<tbody>
				{% if news_list %}
					{% for news in news_list %}
							<tr>
								<td class='center' style="width: 30px;">
									<label><input type='checkbox' name='ids' value="{{news.id}}" /><span class="lbl"></span></label>
								</td>
								<td class='center'>{{news.title|default_if_none:''|truncatechars:15}}</td>
								<td class='center'>{{news.createDate|date:"Y-m-d H:i:s"}}</td>
								<td class='center'>{{news.get_status_display}}</td> 
								<td class='center'>{{news.desc|default_if_none:''|truncatechars:20}}</td>

							</tr>
					{% endfor %} 
					{% else %}
						<tr class="main_info">
							<td colspan="100" class="center" >没有相关数据</td>
						</tr>
					{% endif %}
				
				</tbody>
			</table>
			
		<div class="page-header position-relative">
		<table style="width:100%;">
			<tr>
				
				<td style="vertical-align:top;">
					<div class="pagination" style="float: right;padding-top: 0px;margin-top: 0px;">
						<ul>
							<li>
								<a>共
									<font color="red">{{page.pagesum}}</font>条
								</a>
							</li>
							<li style="cursor:pointer;" onclick="nextPage(1)"><a onclick="nextpage(1)">首页</a></li>
							<li style="cursor:pointer;"><a  onclick="nextPage(2)">上页</a></li>
							<li><a><font color="#808080">{{page.pagenum}}</font></a></li>
							<li style="cursor:pointer;"><a  onclick="nextPage(3)">下页</a></li>
							<li style="cursor:pointer;"><a  onclick="nextPage(4)">尾页</a></li>
							<li><a>共{{page.numpage}}页</a></li>
							<li><select id="selectpageCount" title="显示条数" style="width:55px;float:left;" onchange="changeCount(this.value)">
							<option value="5">5</option>
							<option value="10">10</option>
							<option value="20">20</option>
							<option value="50">50</option>
							<option value="100">100</option>
							</select>
							</li>
						</ul>
					</div>
				</td>
			</tr>
		</table>
		</div>
		</form>
	</div>
 
 
 
 
	<!-- PAGE CONTENT ENDS HERE -->
  </div><!--/row-->
	
</div><!--/#page-content-->
</div><!--/.fluid-container#main-container-->
		
		<!-- 返回顶部  -->
		<a href="#" id="btn-scroll-up" class="btn btn-small btn-inverse">
			<i class="icon-double-angle-up icon-only"></i>
		</a>
		
		<!-- 引入 -->
		<script type="text/javascript">window.jQuery || document.write("<script src='static/js/jquery-1.9.1.min.js'>\x3C/script>");</script>
		<script src="/static/js/bootstrap.min.js"></script>
		<script src="/static/js/ace-elements.min.js"></script>
		<script src="/static/js/ace.min.js"></script>
		
		<script type="text/javascript" src="/static/js/chosen.jquery.min.js"></script><!-- 下拉框 -->
		<script type="text/javascript" src="/static/js/bootstrap-datepicker.min.js"></script><!-- 日期框 -->
		<script type="text/javascript" src="/static/js/bootbox.min.js"></script><!-- 确认窗口 -->
		<!-- 引入 -->
		<script type="text/javascript" src="/static/js/jquery.tips.js"></script><!--提示框-->
		<script type="text/javascript">
		
		function nextPage(type){
			top.jzts();
			pagenumAct = $("#pagenum").val();
			numpage = $("#numpage").val();
			if (pagenumAct == null || pagenumAct== "")
				pagenumAct=1;
			if (numpage == null || numpage== "")
				numpage=1;
			numpage = parseInt(numpage);
			pagenumAct = parseInt(pagenumAct);
			pagenum=1
			if (type == 1){
				if (pagenumAct==1){
					alert("当前已经是首页!");
					top.hangge();
					return;
				}
				
			}else if (type == 2){
				if (pagenumAct==1){
					alert("当前已经是第一页!");
					top.hangge();
					return;
				}
				pagenum = pagenumAct-1
			}else if (type == 3){
				if (pagenumAct==numpage){
					alert("当前已经是最后一页了!");
					top.hangge();
					return;
				}
				pagenum = pagenumAct+1
			}else if (type == 4){
				if (pagenumAct==numpage){
					alert("当前已经是尾页了!");
					top.hangge();
					return;
				}
				pagenum = numpage
			}
			$("#pagenum").val(pagenum);
			$("#Form").submit();
		}
		function changeCount(value){ 
			top.jzts();	
			pagecount = $("#pagecount").val();
			if (pagecount == null || pagecount== "")
				pagecount=10;
			pagecount = parseInt(pagecount);
			if (pagecount == value){
				alert("每页条数未修改!");
				top.hangge();
				return;
			}
			$("#pagenum").val(1);
			$("#pagecount").val(value);
			$("#numpage").val(1);
			$("#Form").submit();
		}
		function toTZ(){
			var toPaggeVlue = document.getElementById("toGoPage").value;
			if(toPaggeVlue == ''){
				document.getElementById("toGoPage").value=1;
				return;
			}
			if(isNaN(Number(toPaggeVlue))){
				document.getElementById("toGoPage").value=1;
				return;
			}
			nextPage(toPaggeVlue);
		}
		
		
		$(top.hangge());
		
		//检索
		function search(){
			top.jzts();
			$("#Form").submit();
		}
		
		
		
		</script>
		
		<script type="text/javascript">
		
		$(function() {
			pagecount = $("#pagecount").val();
			pagecount = parseInt(pagecount);
			 
			$("#selectpageCount").attr("value",pagecount);
			//下拉框
			$(".chzn-select").chosen(); 
			$(".chzn-select-deselect").chosen({allow_single_deselect:true}); 
			
			//日期框
			$('.date-picker').datepicker();
			
			//复选框
			$('table th input:checkbox').on('click' , function(){
				var that = this;
				$(this).closest('table').find('tr > td:first-child input:checkbox')
				.each(function(){
					this.checked = that.checked;
					$(this).closest('tr').toggleClass('selected');
				});
					
			});
			var val = $("#statusold").val();
			if (val != null && val != ""){
				$("#status").attr("value",val);
				$("#status").trigger("liszt:updated");
			}
		});
		 
		
		//导出excel
		function toExcel(){
			window.location.href='<%=basePath%>textmsg/excel.do';
		}
		$(top.hangge());
		</script>
		
	</body>
</html>

